package top.yuyufeng.mbuy.dao;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import top.yuyufeng.mbuy.entity.User;
import top.yuyufeng.mbuy.mapper.UserMapper;

@Repository
public class UserDao {
    @Autowired
    private UserMapper userMapper;

    public void insert(User user) {
        userMapper.insertSelective(user);
    }

    public User getById(Integer id) {
        return userMapper.selectByPrimaryKey(id);
    }

    public User getByUsername(String username) {
        User user = new User();
        user.setUsername(username);
        return userMapper.selectOne(user);
    }


}
